home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0696.zip / DWYER.ZIP / SPECTRAL.TST / CKXMOD.CX < prev    next >
Text File  |  1996-03-09  |  1KB  |  58 lines

  1. /* ============ */
  2. /* ckxmod.cx    */
  3. /* ============ */
  4. #include <xtendefs.h>
  5. #include <stdio.h>
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <xmod.cx>
  9. /* ==================================================================== */
  10. /* */
  11. /* ==================================================================== */
  12.  
  13. #define FLUSH_LINE(u)            \
  14.     {                    \
  15.     int    x;            \
  16.     do                \
  17.     {                \
  18.         x = getc(u);        \
  19.     }                \
  20.     while (x != EOF && x != '\n');    \
  21.     }
  22. /* ==================================================== */
  23. /* GetStr - prompts operator with s to get string Str    */
  24. /* ==================================================== */
  25. void
  26. GetStr(char *s, char *Str)
  27. {
  28.     fprintf(stderr, "%s", s);
  29.  
  30.     scanf("%s", Str);
  31.  
  32.     FLUSH_LINE(stdin);
  33. }
  34. void
  35. main()
  36. {
  37.     char    u[128], v[128];
  38.     USHORT  m[NE], n[NE];
  39.  
  40.    puts("Testing Mod Function:  Needs two integers per call\n");
  41.  
  42.     while (main)
  43.     {
  44.     GetStr("Enter first of the next pair: ", u);
  45.     GetStr("Enter the second:             ", v);
  46.  
  47.     ASCTOX(u, m);
  48.     ASCTOX(v, n);
  49.     XPRINTF("Numer = ", m, 20);
  50.     XPRINTF("Denom = ", n, 20);
  51.     Xmod(m, n, m);
  52. # if 0
  53.     printf("GCD = %.Lf\n", GetGCD(u,v));
  54. # endif
  55.     XPRINTF("Numer % Denom = ", m, 10);
  56.     }
  57. }
  58.